<?php
	require_once 'org/kahikai/domain/User.php';
	require_once 'org/kahikai/fragment/language.php';
	
	use org\kahikai\domain\User;
	
	session_start();
?>
<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" href="style.css" type="text/css"></link>
	<link rel="icon" href="favicon.ico" type="image/x-icon"></link>
	<title>Create kahiKai account</title>
</head>
<body>
<?php
	
	$text = getLocalizedText('create_account');
	echo "\t<form id=\"create_account\" action=\"org/kahikai/action/create_account.php\" method=\"post\">\n";
	if(isset($_SESSION['create_user_errors']) && array_search('exists', $_SESSION['create_user_errors']) !== false)
		echo "\t<label class=\"error_mark\">" . $text['user.exists'] . "</label>\n";
	echo "\t<ul>\n";
	echo "\t\t<li><label for=\"first_name\">" . $text['name.first'] . "</label>\n";
	echo "\t\t<input name=\"first_name\" type=\"text\" id=\"first_name\"";
	if(isset($_SESSION['user']))
		echo ' value="' . $_SESSION['user']->firstName . '"';
	echo "></input>";
	if(isset($_SESSION['create_user_errors']) && array_search('first_name', $_SESSION['create_user_errors']) !== false)
		echo "<label class=\"error_mark\">*</label>";
	echo "</li>\n";
	echo "\t\t<li><label for=\"last_name\">" . $text['name.last'] . "</label>\n";
	echo "\t\t<input name=\"last_name\" type=\"text\" id=\"last_name\"";
	if(isset($_SESSION['user']))
		echo ' value="' . $_SESSION['user']->lastName . '"';
	echo "></input>";
	if(isset($_SESSION['create_user_errors']) && array_search('last_name', $_SESSION['create_user_errors']) !== false)
		echo "<label class=\"error_mark\">*</label>";
	echo "</li>\n";
	echo "\t\t<li><label for=\"email\">" . $text['email'] . "</label>\n";
	echo "\t\t<input name=\"email\" type=\"email\" id=\"email\" placeholder=\"user@kahikai.org\"";
	if(isset($_SESSION['user']))
		echo ' value="' . $_SESSION['user']->email . '"';
	echo "></input>";
	if(isset($_SESSION['create_user_errors']) && array_search('email', $_SESSION['create_user_errors']) !== false)
		echo "<label class=\"error_mark\">*</label>";
	echo "</li>\n";
	echo "\t\t<li><label for=\"email_conf\">" . $text['email.conf'] . "</label>\n";
	echo "\t\t<input name=\"email_conf\" type=\"email\" id=\"email_conf\" placeholder=\"user@kahikai.org\"";
	if(isset($_SESSION['user']))
		echo ' value="' . $_SESSION['user']->email . '"';
	echo "></input>";
	if(isset($_SESSION['create_user_errors']) && array_search('email_conf', $_SESSION['create_user_errors']) !== false)
		echo "<label class=\"error_mark\">*</label>";
	echo "</li>\n";
	echo "\t\t<li><label for=\"password\">" . $text['password'] . "</label>\n";
	echo "\t\t<input name=\"password\" type=\"password\" id=\"password\"></input>";
	if(isset($_SESSION['create_user_errors']) && array_search('password', $_SESSION['create_user_errors']) !== false)
		echo "<label class=\"error_mark\">*</label>";
	echo "</li>\n";
	echo "\t\t<li><label for=\"password_conf\">" . $text['password.conf'] . "</label>\n";
	echo "\t\t<input name=\"password_conf\" type=\"password\" id=\"password_conf\"></input>";
	if(isset($_SESSION['create_user_errors']) && array_search('password_conf', $_SESSION['create_user_errors']) !== false)
		echo "<label class=\"error_mark\">*</label>";
	echo "</li>\n";
	echo "\t\t<li><input type=\"submit\" value=\"" . $text['create'] . "\" id=\"create\"></input></li>\n";
	echo "\t</ul>\n";
	echo "\t</form>\n";
?>
</body>
</html>
